package com.hl.card.modular.packBack.controller;

import com.hl.card.common.controller.BaseController;
import com.hl.card.common.persistence.model.Bibivip;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.hl.card.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.hl.card.modular.packBack.service.IBibivipService;

/**
 * bibivip控制器
 *
 * @author fengshuonan
 * @Date 2018-09-21 15:05:31
 */
@Controller
@RequestMapping("/bibivip")
public class BibivipController extends BaseController {

    private String PREFIX = "/packback/bibivip/";

    @Autowired
    private IBibivipService bibivipService;

    /**
     * 跳转到bibivip首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "bibivip.html";
    }

    /**
     * 跳转到添加bibivip
     */
    @RequestMapping("/bibivip_add")
    public String bibivipAdd() {
        return PREFIX + "bibivip_add.html";
    }

    /**
     * 跳转到修改bibivip
     */
    @RequestMapping("/bibivip_update/{bibivipId}")
    public String bibivipUpdate(@PathVariable Integer bibivipId, Model model) {
        Bibivip bibivip = bibivipService.selectById(bibivipId);
        model.addAttribute("item",bibivip);
        LogObjectHolder.me().set(bibivip);
        return PREFIX + "bibivip_edit.html";
    }

    /**
     * 获取bibivip列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return bibivipService.selectList(null);
    }

    /**
     * 新增bibivip
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(Bibivip bibivip) {
        bibivipService.insert(bibivip);
        return SUCCESS_TIP;
    }

    /**
     * 删除bibivip
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer bibivipId) {
        bibivipService.deleteById(bibivipId);
        return SUCCESS_TIP;
    }

    /**
     * 修改bibivip
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(Bibivip bibivip) {
        bibivipService.updateById(bibivip);
        return SUCCESS_TIP;
    }

    /**
     * bibivip详情
     */
    @RequestMapping(value = "/detail/{bibivipId}")
    @ResponseBody
    public Object detail(@PathVariable("bibivipId") Integer bibivipId) {
        return bibivipService.selectById(bibivipId);
    }
}
